<?php

namespace Addons\SliderShow;
use Common\Controller\Addon;

/**
 * 轮播图插件
 * @author topfany
 */

    class SliderShowAddon extends Addon{

        public $info = array(
            'name'=>'SliderShow',
            'title'=>'轮播图',
            'description'=>'基于slice-box 的首页图片轮播插件',
            'status'=>1,
            'author'=>'topfany',
            'version'=>'0.1'
        );

        public $admin_list = array(
            'list_grid' => array(
            'name'=>'图片名称',
            'describe'=>'图片描叙',
            'url'=>'指向链接',
            'id:操作:[EDIT]|编辑,[DELETE]|删除'
            ),
            'model'=>'Slider',      // 要查的表
            'order'=>'id desc',
            'field'=>'*'            // 查询字段
            
        );

        public function install(){
            return true;
        }

        public function uninstall(){
            return true;
        }

        //实现的sliderShow钩子方法
        public function sliderShow($param){
            $config = $this->getConfig();
            
            //数据库获得相应的信息
            $imgInfo = M('Slider')->select();
            
            
            //var_dump($imgInfo);
            $this->assign("addonsimginfo",$imgInfo);
            
            $this->assign("addonsimgcarousel",$config);
            
            switch ($config['style']) {
                case 1:
                    $temple ='content';
                    break;
                case 2:
                    $temple ='content2';
                    break;
                case 3:
                    $temple ='content3';
                    break;
                case 4:
                    $temple ='content4';
                    break;
                default:
                    $temple = 'content';
                    break;
            }
            $this->display($temple);
        }

    }